www.gusucode.com > LTE基带收发仿真系统matlab源码程序 > LTE baseband simulation/encoderm.m

    function en_output = encoderm( c, g, alpha )
% 功能: Turbo编码器RSC信息生成
% 输入:
%          c:输入信息
%          g:生成器
%      alpha:交织序列
% 输出:
%      en_output:Turbo编码输出
% 
%  Author:		程式小组(徐萌 张妙 张晓庆)
%  Date:		2010-07-11
%  ==========================================================
[n,K] = size(g); 
m = K - 1;
L_info = length(c); 
L_total = L_info + m;  
en_output = zeros(3,L_info+4); % turbo编码输出3流数据,每流后加4位终止比特
input1 = zeros(1,L_info);      % 存放内交织输出数据
% generate the codeword corresponding to the 1st RSC coder
% end = 1, perfectly terminated;
output1 = rsc_encode(g,c,1);

% make a matrix with first row corresponing to info sequence
% second row corresponsing to RSC #1's check bits.
% third row corresponsing to RSC #2's check bits.

y(1,:) = output1(1:2:2*L_total); % 系统比特  xk
y(2,:) = output1(2:2:2*L_total); % 校验比特1 zk


% interleave c to second encoder
for i = 1:L_info
   input1(i) = c(alpha(i)); 
end
output2 = rsc_encode(g,input1, 1 );
y(3,:) = output2(2:2:2*L_total); % 校验比特2 zk'

% Turbo编码的尾比特处理 依据TS 36.212 5.1.3.2.2
tailBits = transpose([output1(2*L_total-5:2:2*L_total);
            output1(2*L_total-4:2:2*L_total);
            output2(2*L_total-5:2:2*L_total);
            output2(2*L_total-4:2:2*L_total)]);
        tailBits([1 5 7 11 4 3 10 9 2 6 8 12]) = tailBits;
en_output(:,1:end-4)=y(:,1:end-3);
en_output(:,end-3:end) = tailBits;
% antipodal modulation: +1/-1
en_output = 2 * en_output - ones(size(en_output));